package com.ruoyi.project.yf.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.yf.domain.YfStockNotice;
import com.ruoyi.project.yf.service.IYfStockNoticeService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 股票通知消息Controller
 * 
 * @author 云峰
 * @date 2020-06-15
 */
@RestController
@RequestMapping("/yf/notice")
public class YfStockNoticeController extends BaseController
{
    @Autowired
    private IYfStockNoticeService yfStockNoticeService;

    /**
     * 查询股票通知消息列表
     */
    @PreAuthorize("@ss.hasPermi('yf:notice:list')")
    @GetMapping("/list")
    public TableDataInfo list(YfStockNotice yfStockNotice)
    {
        startPage();
        List<YfStockNotice> list = yfStockNoticeService.selectYfStockNoticeList(yfStockNotice);
        return getDataTable(list);
    }

    /**
     * 导出股票通知消息列表
     */
    @PreAuthorize("@ss.hasPermi('yf:notice:export')")
    @Log(title = "股票通知消息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(YfStockNotice yfStockNotice)
    {
        List<YfStockNotice> list = yfStockNoticeService.selectYfStockNoticeList(yfStockNotice);
        ExcelUtil<YfStockNotice> util = new ExcelUtil<YfStockNotice>(YfStockNotice.class);
        return util.exportExcel(list, "notice");
    }

    /**
     * 获取股票通知消息详细信息
     */
    @PreAuthorize("@ss.hasPermi('yf:notice:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(yfStockNoticeService.selectYfStockNoticeById(id));
    }

    /**
     * 新增股票通知消息
     */
    @PreAuthorize("@ss.hasPermi('yf:notice:add')")
    @Log(title = "股票通知消息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YfStockNotice yfStockNotice)
    {
        return toAjax(yfStockNoticeService.insertYfStockNotice(yfStockNotice));
    }

    /**
     * 修改股票通知消息
     */
    @PreAuthorize("@ss.hasPermi('yf:notice:edit')")
    @Log(title = "股票通知消息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YfStockNotice yfStockNotice)
    {
        return toAjax(yfStockNoticeService.updateYfStockNotice(yfStockNotice));
    }

    /**
     * 删除股票通知消息
     */
    @PreAuthorize("@ss.hasPermi('yf:notice:remove')")
    @Log(title = "股票通知消息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(yfStockNoticeService.deleteYfStockNoticeByIds(ids));
    }
}
